//
//  UIView+extension.swift
//  iUtil
//
//  Created by wdc on 2019/4/10.
//  Copyright © 2019年 wendachuan. All rights reserved.
//

import UIKit

public extension UIView {
    
    /// 获得指定类名的子视图
    ///
    /// - Parameter name: 待查找的子视图类名
    /// - Returns: 子视图或者nil
    func subviewOfClassName(name: String) -> UIView? {
        for subview in self.subviews {
            if NSStringFromClass(type(of: subview)).compare(name) == ComparisonResult.orderedSame {
                return subview
            }
            if let subview2 = subview.subviewOfClassName(name: name) {
                return subview2
            }
        }
        return nil
    }
}


